#coding:utf-8

"""@author WTBF"""


# 数据输出器

class HtmlOutputer(object):

    """数据输出器"""

    def __init__(self):
        # 定义接收的数据列表
        self.data = []

    # 收集数据到数据列表
    def collect_data(self, data):
        if data is None:
            return
        self.data.append(data)

    # 输出内容至html
    def output_html(self):
        #print "def output_html(self):"
        fout = open('output.html', 'w')

        fout.write('<html><meta charset="utf-8">')
        fout.write('<body>')
        fout.write('<table border="1">')

        #ASCII
        for data in self.data:
            fout.write("<tr>")
            fout.write("<td colspan='1'>%s</td>" % data['url'])
            fout.write("<td colspan='1'>%s</td>" % data['title'])
            fout.write("<td colspan='3'>%s</td>" % data['summary'])
            fout.write("</tr>")

        fout.write('</table>')
        fout.write('</body>')
        fout.write('</html>')